package com.yueka.controller;

import com.yueka.pojo.R;
import com.yueka.pojo.entity.role.Role;
import com.yueka.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RequestMapping("/role")
@RestController
public class RoleController {

    @Autowired
    private RoleService roleService;

    @GetMapping("/list")
    public R list(@RequestParam(value = "keyword", required = false) String keyword,
                  @RequestParam(value = "page", required = false) Integer page,
                  @RequestParam(value = "pageSize", required = false) Integer pageSize) {
        return R.success(roleService.list(keyword, page, pageSize));
    }

    @GetMapping("/delete")
    public R delete(Integer[] ids) {
        return R.success(roleService.delete(ids));
    }

    @GetMapping("/getAll")
    public R getAll() {
        return R.success(roleService.getAll());
    }

    @PostMapping("/update")
    public R update(@RequestBody Role role) {
        return R.success(roleService.update(role));
    }
}
